#include "Customer.h"
#include <iostream>
#include <sstream>

int Customer::uid = 0;


Customer::Customer(void):name(""){
	this->id = uid++;
}

Customer::Customer(const Customer& customer):name(customer.getName()), id(customer.getId()){}

Customer::Customer(const string& customerName):name(customerName){
	this->id = uid++;
}

Customer::~Customer(void){
	//fields deleted auto.
}

const Customer& Customer::operator=(const Customer& customer){

	if (this != &customer){
		this->id = customer.id;
		this->name = customer.name;
	}

	return customer;
}

string Customer::toString() const{
	ostringstream sstm;
	sstm << "id: " << getId() << "\t"
		 << "name: " << getName() << "\t";
	return sstm.str();
}

int Customer::getId() const{
	return this->id;
}

const string& Customer::getName() const{
	return this->name;
}

void Customer::setName(const string& name){
	this->name = name;
}

/*
int main(int argc, char** argv){

	// default constructor test and static field
	Customer c1;
	cout << "c1 name: " << c1.getName() << "\tid:" << c1.getId() << endl;

	// static field test
	Customer c2;
	cout << "c2 name: " << c2.getName() << "\tid:" << c2.getId() << endl;

	// cpy ctor test
	Customer c3 = c2;
	cout << "c3 name: " << c3.getName() << "\tid:" << c3.getId() << endl;

	// string ctor test
	Customer c4("Yosi");
	cout << "c4 name: " << c4.getName() << "\tid:" << c4.getId() << endl;

	// assignment test
	c3 = c4;
	cout << "c3 name: " << c3.getName() << "\tid:" << c3.getId() << endl;

	// setter test
	c3.setName("Zosi");
	cout << "c3 name: " << c3.getName() << "\tid:" << c3.getId() << endl;

	// getter test
	cout << "c3 name: " << c3.getName() << endl;

	getchar();

	return 0;
}
*/